<?php
    if(dis_open()){
        ?>

        <dl>
            <dt>商品是否允许分销：</dt>
            <dd>
                <ul class='ncsc-form-radio-list distribute' >
                    <li>
                        <label>
                            <input name="agree_distribute" value="1" <?php if($gminfo['agree_distribute'] > 0) echo 'checked';?> type="radio">
                            是
                        </label>

                    </li>
                    <li>
                        <label>
                            <input name="agree_distribute" value="0" <?php if(!isset($gminfo['agree_distribute']) || !$gminfo['agree_distribute']) echo 'checked'?> type="radio">
                            否
                        </label>
                    </li>
                </ul>
            </dd>
        </dl>
        <dl>
            <dt>
                分销利润：
            </dt>
            <dd>
        <?php
        if(isset($gminfo['distribute_rate'])){
            $distribute = unserialize($gminfo['distribute_rate']);
        }
        else{
            $distribute = array();
        }

        if(isset($gminfo['dis_inv_rate'])){
            $dis_inv_rate = unserialize($gminfo['dis_inv_rate']);
        }
        else{
            $dis_inv_rate = [];
        }

        ?>
        <?php
        $config = include $_SERVER['DOCUMENT_ROOT'] . '/distribute/include/config.php';

        for ($i = 0; $i < $config['levels']; $i++) {
            ?>
            <div style="clear: both;padding-bottom: 20px;;">
                <div style="float: left;">

                    <input type="text" class='w50 text valid' name='distribute_rate[<?php echo $i ?>]' value='<?php echo $distribute[$i]?>'>
                    <em class="add-on" style="margin-left:-4px">%</em>

                    <p class="hint">
                        <?php echo $i + 1 ?>级分销利润
                    </p>


                </div>
                <div style="float: left;margin-left: 25px;">
                    <input type="text" class='w50 text valid' name='dis_inv_rate[<?php echo $i ?>]' value='<?php echo $dis_inv_rate[$i]?>'>
                    <em class="add-on" style="margin-left:-4px">%</em>

                    <p class="hint">
                        <?php echo $i + 1 ?>级推荐人利润
                    </p>
                </div>
            </div>

            <?php }?>
                <hr style="clear: both;margin-top: 20px;margin-bottom: 10px;">

                <div style='margin-top: 10px;'>
                    <input type="text" class='w50 text valid' name='distribute_special' value='<?php echo $gminfo['distribute_special']?>'>
                    <em class="add-on" style="margin-left:-4px">%</em>

                    <p class="hint">
                        特殊分销商利润
                    </p>
                </div>

                <div style='margin-top: 10px;'>
                    <input type="text" class='w50 text valid' name='dis_spec_rate' value='<?php echo $gminfo['dis_spec_rate']?>'>
                    <em class="add-on" style="margin-left:-4px">%</em>

                    <p class="hint">
                        特殊分销商推荐人利润
                    </p>
                </div>

                <div style='margin-top: 10px;'>
                    <input type="text" class='w50 text valid' name='distribute_price' value='<?php echo $gminfo['distribute_price']?>'>
                    <em class="add-on" style="margin-left:-4px">元</em>

                    <p class="hint">
                        分销价格
                    </p>
                </div>

            </dd>

        </dl>
        <?php
    }
?>